$(document).ready(function () {
    //八音分类
    var byJson = ajaxResult("get", false, "MbXtglBaseTableServlet.getPullData.do", {'tn': 'mb_gy_byfl'});
    loadSelect("#class_bayin", byJson.rows, 'id', 'name');

    var columnsUser = [
        {
            title: '序号', width: '5%', formatter: function (value, row, index) {
            return index + 1;
        }
        },
        {title: '乐器名称', field: 'title'},
        {title: '自称', field: 'title_self'},
        {title: '音标', field: 'phoneticSymbol'},
        {title: '名称解说词', field: 'titleDescription'},
        {title: '霍萨分类', field: 'class_huosa_text'},
        {title: '八音分类', field: 'class_bayin_text'},
        {title: '民间分类', field: 'class_minjian_text'},
        {title: '出土地点', field: 'unearthedPlace'},
        {title: '年代', field: 'year_text'},
        {
            title: '操作', formatter: function (value, row, index) {
            var html = '<a onclick="viewhtml(' + row.id + ')">查看</a>&nbsp;&nbsp;&nbsp;';
            if (row.isrunning == '1') {
                html += '编目中';
            } else {
                html += '<a onclick="addModify(' + row.id + ',this)" data-loading-text="..." >开始编目</a>';
            }
            return html;
        }
        }
    ];
    var params = $("#submitForm").serializeObject();
    params["pageNumber"] = 1;
    params["limit"] = pageSize;
    params["offset"] = 0;
    createTable('#data-table', 'mbgcxxservlet.getMusicList.do', 'id', columnsUser, params);
    $("#query_btn").click(function () {
        refreshTable("#data-table", "#submitForm");
    });
});

function refreshTable(tableid, formid) {
    var params = $(formid).serializeObject();
    params["pageNumber"] = 1;
    params["limit"] = pageSize;
    params["offset"] = 0;
    $(tableid).bootstrapTable('refresh', {query: params});
};
function showhsfl() {
    initSelectModel("Hs", "选择霍萨分类", "class_huosa", 1)
}

function showmjfl() {
    initSelectModel("Mj", "选择民间分类", "class_minjian", 1)
}

function itemUser(id) {
    window.location.href = 'sjbmDetail.html?zdbh=' + id;
}

//加入到编目修改列表中
function addModify(id, ele) {
    $(ele).button('loading').delay(1000).queue(function () {
        $(ele).button('reset');
        $(ele).dequeue();
        var result = ajaxResult('GET', false, '/cnmuseum/bm/create', {"gcxxid": id});
        if (result.status == 'OK') {
            alertFunc('启动编目成功，请在数据编目中查看修改！', function () {
                window.location.href = 'sjbmDetail.html?type=edit&task_id=' + result.data.task_id;
            });
        } else {
            alertFunc(result.msg);
        }
    });
}

function viewhtml(zdbh) {
    window.location.href = 'sjglDetail.html?id=' + zdbh;
}

